package br.com.skytef.beans.WEB;

import java.sql.SQLException;
import java.util.Date;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;

import br.com.skytef.dao.OrderDao;
import br.com.skytef.entity.RelatorioEntradaClientesEntity;
import br.com.skytef.utils.Dates;

@ManagedBean(name="RelatorioEntradaClientesBean")
@RequestScoped
public class RelatorioEntradaClientesHoraBean {

	private Date date;
	private List<RelatorioEntradaClientesEntity> listaClientes;

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}
	
	public List<RelatorioEntradaClientesEntity> getListaClientes() {
		return listaClientes;
	}

	public void setListaClientes(List<RelatorioEntradaClientesEntity> listaClientes) {
		this.listaClientes = listaClientes;
	}
	
	public RelatorioEntradaClientesHoraBean() throws SQLException, Exception {
		date = new Date();
		carregarPagina();
	}
	
	public void carregarPagina() throws SQLException, Exception {
		listaClientes = new OrderDao().clientesPorHora(Dates.dateUtilToSql(date));
	}
			
	// entrada
	public void exibirRelatorioEntrada() throws Exception {
		FacesContext facesContext = FacesContext.getCurrentInstance();
		listaClientes = new OrderDao().clientesPorHora(Dates.dateUtilToSql(date));
	}
	
	public String refresh() throws Exception {
		date = Dates.getDateNow();
		setListaClientes(null);
		return null;
	}

	
}
